package com.travel.controller.user;

import com.travel.constant.ApiConstants;
import com.travel.model.dto.payment.PaymentRequest;
import com.travel.model.entity.payment.Payment;
import com.travel.service.Service.PaymentService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.*;
//用户支付管理接口响应返回数据 , 获取支付记录, 获取支付详情, 创建支付, 取消支付团购
@Tag(name = "用户支付", description = "用户支付管理接口")
@RestController
@RequestMapping(ApiConstants.API_USER + "/payments")
@RequiredArgsConstructor
public class UserPaymentController {
    private final PaymentService paymentService;

    @Operation(summary = "获取支付记录", description = "获取用户的支付记录")
    @GetMapping
    public Page<Payment> getMyPayments(Pageable pageable) {
        return paymentService.getUserPayments(pageable);
    }
    
    @Operation(summary = "支付详情", description = "获取支付详细信息")
    @GetMapping("/{id}")
    public Payment getPayment(
            @Parameter(description = "支付ID") @PathVariable Long id) {
        return paymentService.getPaymentById(id);
    }

    @Operation(summary = "创建支付", description = "创建新的支付订单")
    @PostMapping
    public Payment createPayment(
            @Valid @RequestBody PaymentRequest request) {
        return paymentService.createPayment(request);
    }

    @Operation(summary = "取消支付", description = "取消支付订单")
    @DeleteMapping("/{paymentId}")
    public void cancelPayment(
            @Parameter(description = "支付ID") @PathVariable Long paymentId) {
        paymentService.cancelPayment(paymentId);
    }
} 